home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / asmsrc / st23toexe.lha / ps.s
Encoding:
Text File  |  1989-03-06  |  9.7 KB  |  501 lines

  1. *****************************************************************************
  2. *                                                                           *
  3. * A 2.3 player that runs on interupt and exits on right button              *
  4. * modified by Martyn(Spadge)/17bit                                          *
  5. * core routines by DOC additional code modified from Brian Postmas Player   *
  6. *                                                                           *
  7. * Used for producing executable ST2.3 program files, great for backgrounds  *
  8. * to slideshows etc                                                         *
  9. *                                                                           *
  10. *****************************************************************************
  11.  
  12.         bset    #1,$bfe001 ; led off
  13.  
  14. start:
  15.         bsr    mt_init    ; set interrupts
  16.         lea    inter,a1
  17.         moveq   #5,d0
  18.         move.l  4,a6
  19.         jsr    -168(a6)
  20.         
  21.         
  22. loop:   btst    #2,$dff016 ; wooo, check right mouse
  23.         bne     loop       ; if you wish to check for left button instead
  24.         move.l    4,a6       ; of right then change the first BTST to
  25.         moveq    #32,d0     ; btst  #6,$bfe001 and bingo!
  26.         lea    inter,a1
  27.         jsr    -174(a6)    
  28.         move.w    #$f,$dff096
  29.         clr.l    d0
  30.         rts               ; switch interrupts off
  31.  
  32. *******************************************************
  33. * MAIN ROUTINE                                        *
  34. *                                                     *
  35. * To use this routine in your programs then ignore    *
  36. * the above setion, call MP_INIT first then setup     *
  37. * the interrupts to call the routine MP_MUSIC         *
  38. *                                                     *
  39. * If using this routine in your programs you can also *
  40. * leave out the chunks of code at the following       *     
  41. * labels:                                             *
  42. *                                                     *
  43. * INTER                                               *
  44. * SPADGEWIRQ                                          *
  45. *******************************************************
  46.  
  47.  
  48.  
  49. mt_init:lea    mt_data,a0            ; Call this to set up the music
  50.     add.l    #$03b8,a0
  51.     moveq    #$7f,d0
  52.     moveq    #0,d1
  53. mt_init1:
  54.     move.l    d1,d2
  55.     subq.w    #1,d0
  56. mt_init2:
  57.     move.b    (a0)+,d1
  58.     cmp.b    d2,d1
  59.     bgt.s    mt_init1
  60.     dbf    d0,mt_init2
  61.     addq.b    #1,d2
  62.  
  63. mt_init3:
  64.     lea    mt_data,a0
  65.     lea    mt_sample1(pc),a1
  66.     asl.l    #8,d2
  67.     asl.l    #2,d2
  68.     add.l    #$438,d2
  69.     add.l    a0,d2
  70.     moveq    #$1e,d0
  71. mt_init4:
  72.     move.l    d2,(a1)+
  73.     moveq    #0,d1
  74.     move.w    42(a0),d1
  75.     asl.l    #1,d1
  76.     add.l    d1,d2
  77.     add.l    #$1e,a0
  78.     dbf    d0,mt_init4
  79.  
  80.     lea    mt_sample1(PC),a0
  81.     moveq    #0,d0
  82. mt_clear:
  83.     move.l    (a0,d0.w),a1
  84.     clr.l    (a1)
  85.     addq.w    #4,d0
  86.     cmp.w    #$7c,d0
  87.     bne.s    mt_clear
  88.  
  89.     clr.w    $dff0a8
  90.     clr.w    $dff0b8
  91.     clr.w    $dff0c8
  92.     clr.w    $dff0d8
  93.     clr.l    mt_partnrplay
  94.     clr.l    mt_partnote
  95.     clr.l    mt_partpoint
  96.  
  97.     move.b    mt_data+$3b6,mt_maxpart+1
  98.     rts
  99.  
  100. mt_end:    clr.w    $dff0a8
  101.     clr.w    $dff0b8
  102.     clr.w    $dff0c8
  103.     clr.w    $dff0d8
  104.     move.w    #$f,$dff096
  105.     rts
  106.  
  107. **************************************
  108.  
  109. spadgewirq:
  110.  movem.l    d0-d7/a0-a6,-(a7)
  111.  bsr        mt_music
  112.  movem.l    (a7)+,d0-d7/a0-a6
  113.  moveq        #0,d0
  114.  rts
  115.  
  116. **************************************
  117.  
  118. mt_music:                                    ; call this on interrupt 
  119.     addq.w    #1,mt_counter                
  120. mt_cool:cmp.w    #6,mt_counter
  121.     bne.s    mt_notsix
  122.     clr.w    mt_counter
  123.     bra    mt_rout2
  124.  
  125. mt_notsix:
  126.     lea    mt_aud1temp(PC),a6
  127.     tst.b    3(a6)
  128.     beq.s    mt_arp1
  129.     lea    $dff0a0,a5        
  130.     bsr.s    mt_arprout
  131. mt_arp1:lea    mt_aud2temp(PC),a6
  132.     tst.b    3(a6)
  133.     beq.s    mt_arp2
  134.     lea    $dff0b0,a5
  135.     bsr.s    mt_arprout
  136. mt_arp2:lea    mt_aud3temp(PC),a6
  137.     tst.b    3(a6)
  138.     beq.s    mt_arp3
  139.     lea    $dff0c0,a5
  140.     bsr.s    mt_arprout
  141. mt_arp3:lea    mt_aud4temp(PC),a6
  142.     tst.b    3(a6)
  143.     beq.s    mt_arp4
  144.     lea    $dff0d0,a5
  145.     bra.s    mt_arprout
  146. mt_arp4:rts
  147.  
  148. mt_arprout:
  149.     move.b    2(a6),d0
  150.     and.b    #$0f,d0
  151.     tst.b    d0
  152.     beq    mt_arpegrt
  153.     cmp.b    #$01,d0
  154.     beq.s    mt_portup
  155.     cmp.b    #$02,d0
  156.     beq.s    mt_portdwn
  157.     cmp.b    #$0a,d0
  158.     beq.s    mt_volslide
  159.     rts
  160.  
  161. mt_portup:
  162.     moveq    #0,d0
  163.     move.b    3(a6),d0
  164.     sub.w    d0,22(a6)
  165.     cmp.w    #$71,22(a6)
  166.     bpl.s    mt_ok1
  167.     move.w    #$71,22(a6)
  168. mt_ok1:    move.w    22(a6),6(a5)
  169.     rts
  170.  
  171. mt_portdwn:
  172.     moveq    #0,d0
  173.     move.b    3(a6),d0
  174.     add.w    d0,22(a6)
  175.     cmp.w    #$538,22(a6)
  176.     bmi.s    mt_ok2
  177.     move.w    #$538,22(a6)
  178. mt_ok2:    move.w    22(a6),6(a5)
  179.     rts
  180.  
  181. mt_volslide:
  182.     moveq    #0,d0
  183.     move.b    3(a6),d0
  184.     lsr.b    #4,d0
  185.     tst.b    d0
  186.     beq.s    mt_voldwn
  187.     add.w    d0,18(a6)
  188.     cmp.w    #64,18(a6)
  189.     bmi.s    mt_ok3
  190.     move.w    #64,18(a6)
  191. mt_ok3:    move.w    18(a6),8(a5)
  192.     rts
  193. mt_voldwn:
  194.     moveq    #0,d0
  195.     move.b    3(a6),d0
  196.     and.b    #$0f,d0
  197.     sub.w    d0,18(a6)
  198.     bpl.s    mt_ok4
  199.     clr.w    18(a6)
  200. mt_ok4:    move.w    18(a6),8(a5)
  201.     rts
  202.  
  203. mt_arpegrt:
  204.     move.w    mt_counter(PC),d0
  205.     cmp.w    #1,d0
  206.     beq.s    mt_loop2
  207.     cmp.w    #2,d0
  208.     beq.s    mt_loop3
  209.     cmp.w    #3,d0
  210.     beq.s    mt_loop4
  211.     cmp.w    #4,d0
  212.     beq.s    mt_loop2
  213.     cmp.w    #5,d0
  214.     beq.s    mt_loop3
  215.     rts
  216.  
  217. mt_loop2:
  218.     moveq    #0,d0
  219.     move.b    3(a6),d0
  220.     lsr.b    #4,d0
  221.     bra.s    mt_cont
  222. mt_loop3:
  223.     moveq    #$00,d0
  224.     move.b    3(a6),d0
  225.     and.b    #$0f,d0
  226.     bra.s    mt_cont
  227. mt_loop4:
  228.     move.w    16(a6),d2
  229.     bra.s    mt_endpart
  230. mt_cont:
  231.     add.w    d0,d0
  232.     moveq    #0,d1
  233.     move.w    16(a6),d1
  234.     lea    mt_arpeggio(PC),a0
  235. mt_loop5:
  236.     move.w    (a0,d0),d2
  237.     cmp.w    (a0),d1
  238.     beq.s    mt_endpart
  239.     addq.l    #2,a0
  240.     bra.s    mt_loop5
  241. mt_endpart:
  242.     move.w    d2,6(a5)
  243.     rts
  244.  
  245. mt_rout2:
  246.     lea    mt_data,a0
  247.     move.l    a0,a3
  248.     add.l    #$0c,a3
  249.     move.l    a0,a2
  250.     add.l    #$3b8,a2
  251.     add.l    #$43c,a0
  252.     move.l    mt_partnrplay(PC),d0
  253.     moveq    #0,d1
  254.     move.b    (a2,d0),d1
  255.     asl.l    #8,d1
  256.     asl.l    #2,d1
  257.     add.l    mt_partnote(PC),d1
  258.     move.l    d1,mt_partpoint
  259.     clr.w    mt_dmacon
  260.  
  261.     lea    $dff0a0,a5
  262.     lea    mt_aud1temp(PC),a6
  263.     bsr    mt_playit
  264.     lea    $dff0b0,a5
  265.     lea    mt_aud2temp(PC),a6
  266.     bsr    mt_playit
  267.     lea    $dff0c0,a5
  268.     lea    mt_aud3temp(PC),a6
  269.     bsr    mt_playit
  270.     lea    $dff0d0,a5
  271.     lea    mt_aud4temp(PC),a6
  272.     bsr    mt_playit
  273.     move.w    #$01f4,d0
  274. mt_rls:    dbf    d0,mt_rls
  275.  
  276.     move.w    #$8000,d0
  277.     or.w    mt_dmacon,d0
  278.     move.w    d0,$dff096
  279.  
  280.     lea    mt_aud4temp(PC),a6
  281.     cmp.w    #1,14(a6)
  282.     bne.s    mt_voice3
  283.     move.l    10(a6),$dff0d0
  284.     move.w    #1,$dff0d4
  285. mt_voice3:
  286.     lea    mt_aud3temp(PC),a6
  287.     cmp.w    #1,14(a6)
  288.     bne.s    mt_voice2
  289.     move.l    10(a6),$dff0c0
  290.     move.w    #1,$dff0c4
  291. mt_voice2:
  292.     lea    mt_aud2temp(PC),a6
  293.     cmp.w    #1,14(a6)
  294.     bne.s    mt_voice1
  295.     move.l    10(a6),$dff0b0
  296.     move.w    #1,$dff0b4
  297. mt_voice1:
  298.     lea    mt_aud1temp(PC),a6
  299.     cmp.w    #1,14(a6)
  300.     bne.s    mt_voice0
  301.     move.l    10(a6),$dff0a0
  302.     move.w    #1,$dff0a4
  303. mt_voice0:
  304.     move.l    mt_partnote(PC),d0
  305.     add.l    #$10,d0
  306.     move.l    d0,mt_partnote
  307.     cmp.l    #$400,d0
  308.     bne.s    mt_stop
  309. mt_higher:
  310.     clr.l    mt_partnote
  311.     addq.l    #1,mt_partnrplay
  312.     moveq    #0,d0
  313.     move.w    mt_maxpart(PC),d0
  314.     move.l    mt_partnrplay(PC),d1
  315.     cmp.l    d0,d1
  316.     bne.s    mt_stop
  317.     clr.l    mt_partnrplay
  318.  
  319. mt_stop:tst.w    mt_status                        ; Like it says, STOP!
  320.     beq.s    mt_stop2
  321.     clr.w    mt_status
  322.     bra.s    mt_higher
  323. mt_stop2:
  324.     rts
  325.  
  326. mt_playit:
  327.     move.l    (a0,d1.l),(a6)
  328.     addq.l    #4,d1
  329.     moveq    #0,d2
  330.     move.b    2(a6),d2
  331.     and.b    #$f0,d2
  332.     lsr.b    #4,d2
  333.  
  334.     move.b    (a6),d0
  335.     and.b    #$f0,d0
  336.     or.b    d0,d2
  337.     tst.b    d2
  338.     beq.s    mt_nosamplechange
  339.  
  340.     moveq    #0,d3
  341.     lea    mt_samples(PC),a1
  342.     move.l    d2,d4
  343.     asl.l    #2,d2
  344.     mulu    #$1e,d4
  345.     move.l    (a1,d2),4(a6)
  346.     move.w    (a3,d4.l),8(a6)
  347.     move.w    2(a3,d4.l),18(a6)
  348.     move.w    4(a3,d4.l),d3
  349.     tst.w    d3
  350.     beq.s    mt_displace
  351.     move.l    4(a6),d2
  352.     add.l    d3,d2
  353.     move.l    d2,4(a6)
  354.     move.l    d2,10(a6)
  355.     move.w    6(a3,d4.l),8(a6)
  356.     move.w    6(a3,d4.l),14(a6)
  357.     move.w    18(a6),8(a5)
  358.     bra.s    mt_nosamplechange
  359.  
  360. mt_displace:
  361.     move.l    4(a6),d2
  362.     add.l    d3,d2
  363.     move.l    d2,10(a6)
  364.     move.w    6(a3,d4.l),14(a6)
  365.     move.w    18(a6),8(a5)
  366. mt_nosamplechange:
  367.     tst.w    (a6)
  368.     beq.s    mt_retrout
  369.     move.w    (a6),16(a6)
  370.     move.w    20(a6),$dff096
  371.     move.l    4(a6),(a5)
  372.     move.w    8(a6),4(a5)
  373.     move.w    (a6),6(a5)
  374.     move.w    20(a6),d0
  375.     or.w    d0,mt_dmacon
  376.  
  377. mt_retrout:
  378.     tst.w    (a6)
  379.     beq.s    mt_nonewper
  380.     move.w    (a6),22(a6)
  381.  
  382. mt_nonewper:
  383.     move.b    2(a6),d0
  384.     and.b    #$0f,d0
  385.     cmp.b    #$0b,d0
  386.     beq.s    mt_posjmp
  387.     cmp.b    #$0c,d0
  388.     beq.s    mt_setvol
  389.     cmp.b    #$0d,d0
  390.     beq.s    mt_break
  391.     cmp.b    #$0e,d0
  392.     beq.s    mt_setfil
  393.     cmp.b    #$0f,d0
  394.     beq.s    mt_setspeed
  395.     rts
  396.  
  397. mt_posjmp:
  398.     not.w    mt_status
  399.     moveq    #0,d0
  400.     move.b    3(a6),d0
  401.     subq.b    #1,d0
  402.     move.l    d0,mt_partnrplay
  403.     rts
  404.  
  405. mt_setvol:
  406.     move.b    3(a6),8(a5)
  407.     rts
  408.  
  409. mt_break:
  410.     not.w    mt_status
  411.     rts
  412.  
  413. mt_setfil:
  414.     moveq    #0,d0
  415.     move.b    3(a6),d0
  416.     and.b    #1,d0
  417.     rol.b    #1,d0
  418.     and.b    #$fd,$bfe001
  419.     or.b    d0,$bfe001
  420.     rts
  421.  
  422. mt_setspeed:
  423.     move.b    3(a6),d0
  424.     and.b    #$0f,d0
  425.     beq.s    mt_back
  426.     clr.w    mt_counter
  427.     move.b    d0,mt_cool+3
  428. mt_back:rts
  429.  
  430. mt_aud1temp:
  431.     blk.w    10,0
  432.     dc.w    1
  433.     blk.w    2,0
  434. mt_aud2temp:
  435.     blk.w    10,0
  436.     dc.w    2
  437.     blk.w    2,0
  438. mt_aud3temp:
  439.     blk.w    10,0
  440.     dc.w    4
  441.     blk.w    2,0
  442. mt_aud4temp:
  443.     blk.w    10,0
  444.     dc.w    8
  445.     blk.w    2,0
  446.  
  447. mt_partnote:    dc.l    0
  448. mt_partnrplay:    dc.l    0
  449. mt_counter:    dc.w    0
  450. mt_partpoint:    dc.l    0
  451. mt_samples:    dc.l    0
  452. mt_sample1:    blk.l    31,0
  453. mt_maxpart:    dc.w    0
  454. mt_dmacon:    dc.w    0
  455. mt_status:    dc.w    0
  456.  
  457. **************************************
  458.  
  459. inter:
  460.          dc.l    0,0
  461.          dc.b    2,127
  462.           dc.l    0,0
  463.          dc.l    spadgewirq
  464.  
  465. **************************************
  466.  
  467. mt_arpeggio:
  468.     dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c
  469.     dc.w $023a,$021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d
  470.     dc.w $0168,$0153,$0140,$012e,$011d,$010d,$00fe,$00f0
  471.     dc.w $00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097
  472.     dc.w $008f,$0087,$007f,$0078,$0071,$0000,$0000,$0000
  473.  
  474. mt_data:    blk.b    57536,0   ; bung module length here!
  475.                                   ; the first figure is the length of
  476.                                   ; the soundtracker module you are using
  477.                                   ; 57536 is the length of the example 
  478.                                   ; which we used as the Newsflash background
  479.                                   ; track (Chung Kuo by Mark Wilson)
  480.  
  481.  
  482.  
  483. ; Instructions to create an executable SOUNDTRACKER 2.3 file
  484. ;
  485. ; 1) Assemble this file (set up for SEKA at moment, no ERRORS! hehe)
  486. ;    Remembering to check length of the module to use, insert this at
  487. ;    Mt_data as shown above.
  488. ;
  489. ; 2) Include the module by loading the data at Mt_data
  490. ;    Specifying the START at Mt_data, the end at Mt_data + Modulelength
  491. ;    (module length in above case was 57536)
  492. ;
  493. ; 3) Now save the object-file, if possible save it so it loads into CHIP mem.
  494. ;
  495. ; 4) Run the program and all is fine. If you hear corrupt sounds then turn
  496. ;    fast mem off or make the file default to chip using Powerpacker or a
  497. ;    similar program such as Fixhunk.
  498. ;
  499. ; ENJOY!
  500.  
  501.